package edu.cmu.fithub.db;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class DBHelper {

	private static final SessionFactory sessionFactory;
	
	static {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
        	Class.forName("com.mysql.jdbc.Driver");
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            System.out.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
	
}
